#!/bin/ksh
# (jbh) added -f option to overwrite files in the destination
# (jbh) created 11/18/97 (4:47pm)

#Sets up links from all config tool files in the source Directory (which is the
#directory containing this script) to the current directory .  It also copies the
#cfg.ini file to the local directory, so there won't be problems with writing it.
#This effectively allows users to run config tools from AFS, or any shared directory
#while avoiding any concurrency problems.

command=$0
option=$1
overwrite=0
if [ -n option ]; then
   if [ option='-h' ]; then
      overwrite=1
   fi
fi
sourceDir=`echo $command | sed 's/\/[A-Za-z0-9\.\_]*$//g'`'/'
currentDir=`pwd`'/'
for file in cfg cfg.aix cfg.app cfg.hlp cfg.lgo cfg.msg headless.app batch.txt '#BATCH.cos' '#BATCHSC.cos' '#CONNECT.cos' '#INTER.cos' '#INTERSC.cos' 'CPSVCMG.cos' 'SNASVCMG.cos'
do                                                                         
     if [ -r $sourceDir$file ]; then     
	echo 'Setting up link for '$file                                   
        if [ overwrite -eq 1 ]; then
           ln -sf $sourceDir$file $currentDir$file
        else
           ln -s $sourceDir$file $currentDir$file                                           
        fi
     fi
done                                                                       
echo 'Copying preferences file to local directory'                         
cp $sourceDir'cfg.ini' $currentDir                                                      
echo 'Done.  Please run cfg from this directory to start the tool'
